import 'package:backend.core/core/domain/entities/app_store/app_store_purchased_subscription_expiration_reason.dart';
import 'package:backend.purchases/domain/entities/app_store_api/app_store_api_purchased_subscription_expiration_reason.dart';

abstract class CreateAppStorePurchasedSubscriptionExpirationReasonFromApiOne {
  AppStorePurchasedSubscriptionExpirationReason call({
    required AppStoreApiPurchasedSubscriptionExpirationReason apiExpirationReason,
  });
}

class CreateAppStorePurchasedSubscriptionExpirationReasonFromApiOneImpl
    implements CreateAppStorePurchasedSubscriptionExpirationReasonFromApiOne {
  const CreateAppStorePurchasedSubscriptionExpirationReasonFromApiOneImpl();

  @override
  AppStorePurchasedSubscriptionExpirationReason call({
    required AppStoreApiPurchasedSubscriptionExpirationReason apiExpirationReason,
  }) {
    switch (apiExpirationReason) {
      case AppStoreApiPurchasedSubscriptionExpirationReason.customerCancellation:
        return AppStorePurchasedSubscriptionExpirationReason.customerCancellation;
      case AppStoreApiPurchasedSubscriptionExpirationReason.billingError:
        return AppStorePurchasedSubscriptionExpirationReason.billingError;
      case AppStoreApiPurchasedSubscriptionExpirationReason.priceIncrease:
        return AppStorePurchasedSubscriptionExpirationReason.priceIncrease;
      case AppStoreApiPurchasedSubscriptionExpirationReason.unavailablePurchase:
        return AppStorePurchasedSubscriptionExpirationReason.unavailablePurchase;
    }
  }
}
